package com.ctshk.sapp.localfun.controller;

import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.localfun.dto.LocalFunResourceDTO;
import com.ctshk.rpc.localfun.dto.LocalFunResourceDetailDTO;
import com.ctshk.rpc.localfun.req.*;
import com.ctshk.rpc.localfun.service.ILocalFunResourceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * @author 万思
 * @descroption 当地游玩 - 资源中心 -controller service layer api接口
 * @since
 */
@RestController
@RequestMapping("/local-fun-resource")
@Api(value = "当地游玩-资源中心", tags = "当地游玩-资源中心")
public class LocalFunResourceController extends BaseController{

    @DubboReference
    private ILocalFunResourceService iLocalFunResourceService;

    @ApiOperation(value = "产品列表", notes = "产品列表",tags = "当地游玩-资源中心")
    @PostMapping(value = "/query-list")
    public Result<PageResponse<LocalFunResourceDTO>> queryList(@RequestBody LocalFunResourceReq localFunResourceReq) {
        Result<PageResponse<LocalFunResourceDTO>> success = Result.success(iLocalFunResourceService.queryList(localFunResourceReq,getCurrentUser()));
        return success;
    }

    @ApiOperation(value = "产品列表-提供给推广码", notes = "产品列表",tags = "当地游玩-资源中心")
    @PostMapping(value = "/list")
    public Result<PageResponse<LocalFunResourceDTO>> list(@RequestBody LocalFunResourceReq localFunResourceReq) {
        Result<PageResponse<LocalFunResourceDTO>> success = Result.success(iLocalFunResourceService.queryListByProductIds(localFunResourceReq));
        return success;
    }

    @ApiOperation(value = "批量修改售卖状态", notes = "批量修改售卖状态",tags = "当地游玩-资源中心")
    @PostMapping(value = "/update-sale-status")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.UPDATE, operTitle = "当地游玩产品售卖状态修改", operDesc = "当地游玩产品售卖状态修改")
    public Result<Long> updateSaleStatus(@RequestBody LocalFunResourceSaleReq localFunResourceSaleReq) {
        return iLocalFunResourceService.updateSaleStatus(localFunResourceSaleReq, getCurrentUser(getRequest()));
    }

    @ApiOperation(value = "新增当地游玩产品信息-产品设置", notes = "新增地游玩产品信息-产品设置",tags = "当地游玩-资源中心")
    @PostMapping(value = "/save")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.ADD, operTitle = "地游玩产品售卖状态新增", operDesc = "地游玩产品售卖状态新增")
    public Result<Long> save(@RequestBody LocalFunResourceProductReq resourceProductReq) {
        return iLocalFunResourceService.save(resourceProductReq, getCurrentUser(getRequest()));
    }

    @ApiOperation(value = "编辑当地游玩产品信息-产品设置", notes = "门票信息-产品设置编辑")
    @PostMapping(value = "/modify")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.UPDATE, operTitle = "门票售卖状态编辑", operDesc = "门票售卖状态编辑")
    public Result<Long> modify(@RequestBody @Valid LocalFunResourceProductReq resourceProductReq) {
        return iLocalFunResourceService.modify(resourceProductReq,getCurrentUser(getRequest()));
    }


    @ApiOperation(value = "新增/编辑当地游玩产品信息-预订设置", notes = "新增/编辑地游玩产品信息-预订设置",tags = "当地游玩-资源中心")
    @PostMapping(value = "/save-subscribe")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.ADD, operTitle = "地游玩产品售卖状态新增", operDesc = "地游玩产品售卖状态新增")
    public Result<Long> saveAgent(@RequestBody LocalFunProductSaveReq scenicProductSaveReq) {
        return iLocalFunResourceService.saveAgent(scenicProductSaveReq);
    }

    @ApiOperation(value = "新增-编辑提交审批", notes = "新增-编辑提交审批",tags = "当地游玩-资源中心")
    @PostMapping(value = "/update-approval-status")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.UPDATE, operTitle = "门票售卖状态修改", operDesc = "门票售卖状态修改")
    public Result<String> submit(@RequestBody LocalFunProductSubmitReq localFunProductSubmitReq) {
        return iLocalFunResourceService.submit(localFunProductSubmitReq,getCurrentUser(getRequest()));
    }

    @ApiOperation(value = "新增-审批", notes = "新增-审批")
    @PostMapping(value = "/update-approval-check")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.UPDATE, operTitle = "门票售卖状态修改", operDesc = "门票售卖状态修改")
    public Result<Long> check(@RequestBody LocalFunProductCheckReq localFunProductCheckReq) {

        return iLocalFunResourceService.check(localFunProductCheckReq,getCurrentUser(getRequest()));
    }


    @ApiOperation(value = "api批量设置", notes = "api批量设置")
    @PostMapping(value = "/update-api")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.UPDATE, operTitle = "api批量设置", operDesc = "api批量设置")
    public Result<Long> updateApi(@RequestBody LocalFunResourceApiReq resourceApiReq) {
        return iLocalFunResourceService.updateApi(resourceApiReq);
    }

    @ApiOperation(value = "查询当地游玩产品详情", notes = "查询当地游玩产品详情",tags = "当地游玩-资源中心")
    @PostMapping(value = "/detail")
    public Result<LocalFunResourceDetailDTO> detail(@RequestBody LocalFunResourceDetailReq req) {
        return iLocalFunResourceService.detail(req.getId(),req.getQueryDate(),getCurrentUser(getRequest()));
    }

    @ApiOperation(value = "查询当地游玩产品详情-提供其他模块使用", notes = "查询当地游玩产品详情",tags = "当地游玩-资源中心")
    @PostMapping(value = "/product-detail")
    public Result<LocalFunResourceDetailDTO> productDetail(@RequestBody LocalFunResourceDetailReq req) {
        return iLocalFunResourceService.productDetail(req.getId());
    }

//    @PostMapping(value = "/test")
//    public void test() {
//         iLocalFunResourceService.testTX();
//    }
}
